//
//  Blurrer
//
//  Created by Wonil Suh on 2009-07-20.
//  Copyright (c) 2009 secret toilet. All rights reserved.
//  Contact: wosuh@secretToilet.com
//  
//  DESCRIPTION
//  

package com.wonilsuh.display {
	
	// import
	import flash.display.DisplayObject;
	
	import fl.transitions.Tween;
	import fl.transitions.easing.Strong;
	
	import flash.filters.BitmapFilter;
	import flash.filters.BitmapFilterQuality;
	import flash.filters.BlurFilter;
	
	public class Blurrer extends Object {

		// properties
		private var tObj:DisplayObject;
		private var twnB:Tween;
		private var _blurAmount:Number;
		
		// timeline elements
		
		// constants
		
		//----------------------------------------
		// constructor
		public function Blurrer(pTObj:DisplayObject) {
			//trace("Blurrer has been constructed.");
			tObj = pTObj;
		}
		
		public function blurTween(from:Number, to:Number, easing:Function, duration:Number=1):void {
			//trace(".blurTween()...");
			twnB = new Tween(this, "blurAmount", easing, from, to, duration, true);
		}

		//----------------------------------------
		// init methods
		
		//----------------------------------------
		// methods
		
		//----------------------------------------
		// getters and setters
		public function set blurAmount(pba:Number):void {
			//trace(".set blurAmount()...");
			_blurAmount = pba;
			setBlur();
		}
		
		public function get blurAmount():Number {
			//trace(".get blurAmount()...");
			return _blurAmount;
		}
		
		private function setBlur():void {
			//trace(".setBlur()...");
			var blur:BitmapFilter = new BlurFilter(_blurAmount, _blurAmount, BitmapFilterQuality.HIGH);
			var filterArray:Array = new Array();
			filterArray.push(blur);
			tObj.filters = filterArray;
		}
		
		//----------------------------------------
		// interface implementations
		
	}
}